import 'package:flutter/material.dart';


// AnimatedOpacity    AnimationController  AnimatedPositioned  RotationTransition

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("AnimatedContainer Gradient Demo")),
        body: const AnimatedGradientDemo(),
      ),
    );
  }
}

class AnimatedGradientDemo extends StatefulWidget {
  const AnimatedGradientDemo({super.key});

  @override
  _AnimatedGradientDemoState createState() => _AnimatedGradientDemoState();
}

class _AnimatedGradientDemoState extends State<AnimatedGradientDemo> {
  List<Color> _colors = [Colors.blue, Colors.green];

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          AnimatedContainer(
            width: 150,
            height: 150,
            decoration: BoxDecoration(
              gradient: LinearGradient(
                colors: _colors,
                begin: Alignment.topLeft,
                end: Alignment.bottomRight,
              ),
            ),
            duration: const Duration(seconds: 1),
            curve: Curves.easeInOut,
            child: const Center(
              child: Text(
                'Gradient Animate',
                style: TextStyle(color: Colors.white),
              ),
            ),
          ),
          const SizedBox(height: 20),
          ElevatedButton(
            onPressed: () {
              setState(() {
                _colors = _colors[0] == Colors.blue
                    ? [Colors.red, Colors.yellow]
                    : [Colors.blue, Colors.green];
              });
            },
            child: const Text('Animate Gradient'),
          ),
        ],
      ),
    );
  }
}
